import { View } from "../../../mvc/core/View";
import { DragEvent } from "../../../../com/mui/events/DragEvent";
import { BaseItem } from "../common/BaseItem";
import { ItemData } from "../../resource/info/ItemData";
import { GoodsItem } from "../common/GoodsItem";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { DataEvent } from "../../events/DataEvent";
import { MsgManager } from "../../manager/MsgManager";
import { Language } from "../../../../extend/language/Language";
import { EPlayerItemPosType } from "../../../../Message/Public/EPlayerItemPosType";
import { GComboBox } from "../../../../com/mui/controls/GComboBox";
import { ColorConfig } from "../../resource/ColorConfig";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { TextAlign } from "../../../../flashx/textLayout/formats/TextAlign";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { Cache } from "../../cache/Cache";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { EMergeType } from "../../../../Message/Public/EMergeType";
import { ItemExInfo } from "../../resource/info/ItemExInfo";
import { ItemsUtil } from "../shortcuts/item/ItemsUtil";
import { Alert } from "../../../../com/mui/controls/Alert";
import { EquipmentItemDataUtil } from "../common/EquipmentItemDataUtil";
import { EColor } from "../../../../Message/Public/EColor";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { EquipmentUtil } from "../common/util/EquipmentUtil";
import { WingList } from "../wardrobe/WingList";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { GImageButtonTabBar } from "../../../../com/mui/controls/GImageButtonTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ResFileConst } from "../../resource/ResFileConst";
import { MountComboBoxItemCellRender } from "../mounts/cell/MountComboBoxItemCellRender";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { PetProcessBar } from "../pet/PetProcessBar";
import { WardrobeType } from "../wardrobe/WardrobeType";
import { WingFusionAlertWindow } from "../wardrobe/WingFusionAlertWindow";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class FashionBoxMergePanel
    
    export  class FashionBoxMergePanel extends View
    {
        constructor()
        {
            super();
            this._displayListArr = [];
            this.rtnArray = [];
            this.init();
            return;
        }

        /* internal  */onDeputyComboChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._deputyCombo.selectedItem.value;
            this.moveInDeputyItem(loc1);
            if (loc1 && this._mainItemData) 
            {
                if (this._mainItemData.color < loc1.color) 
                {
                    return;
                }
            }
            this.setSelectedItemCombox(loc1, this._deputyCombo);
            return;
        }

        /* internal  */onMainComboChangehandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._mainCombo.selectedItem.value;
            this.moveInMainItem(loc1);
            this.setSelectedItemCombox(loc1, this._mainCombo);
            return;
        }

        /* internal  */onDeputyMoveInHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as BaseItem;
            if (loc1) 
            {
                if (loc1 && loc1 is BaseItem) 
                {
                    loc2 = loc1.itemData;
                    this.moveInDeputyItem(loc2);
                }
            }
            return;
        }

        /* internal  */onMainMoveInHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as BaseItem;
            if (loc1) 
            {
                if (loc1 && loc1 is BaseItem) 
                {
                    loc2 = loc1.itemData;
                    this.moveInMainItem(loc2);
                }
            }
            return;
        }

        /* internal  */moveInMainItem(arg1: ItemData): void
        {
            this.updateMainInfo(arg1);
            return;
        }

        /* internal  */moveInDeputyItem(arg1: ItemData): void
        {
            this.updateDeputyInfo(arg1);
            return;
        }

        /* internal  */onDeputyItemClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            this.clearDeputyItem();
            return;
        }

        /* internal  */createGoodsItem(arg1: int, arg2: int, arg3: int, arg4: int, arg5: int, arg6: Object /* flash.display.DisplayObjectContainer */): GoodsItem
        {
            var loc1;
            (loc1 = new GoodsItem()).posIndex = arg1;
            loc1.move(arg2, arg3);
            loc1.setSize(arg4, arg5);
            loc1.setOverPosition(-2, -2);
            arg6.addChild(loc1);
            return loc1;
        }

        /* internal  */onLoadBmResourceII(): void
        {
            this._stBmWingFusionBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountExtendBg);
            return;
        }

        /* internal  */onMainItemClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            this.clearMainItem();
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stBmStreng.bitmapData = GlobalClass.getBitmapData(ImagesConst.FusionStrengthen);
            this._stBmPrefix.bitmapData = GlobalClass.getBitmapData(ImagesConst.FusionPreFix);
            this._stBmMerge.bitmapData = GlobalClass.getBitmapData(ImagesConst.FusionLevel);
            this._stBmFusionAtrribute.bitmapData = GlobalClass.getBitmapData(ImagesConst.FusionAtrribute);
            this._stBmFusionAttributeAdd.bitmapData = GlobalClass.getBitmapData(ImagesConst.FusionAttributeAdd);
            return;
        }

        /* internal  */onMergeChangeHandler(arg1: DataEvent): void
        {
            var loc1=arg1.data as ItemData;
            this.updateInfo(loc1);
            return;
        }

        /* internal  */updateInfo(arg1: ItemData): void
        {
            if (this._mainItemData != null) 
            {
                if (this._deputyItemData == null) 
                {
                    this.updateDeputyInfo(arg1);
                }
            }
            else 
            {
                this.updateMainInfo(arg1);
            }
            return;
        }

        /* internal  */updateMainInfo(arg1: ItemData): void
        {
            if (arg1 && this._deputyItemData && this._deputyItemData.uid == arg1.uid) 
            {
                this.clearDeputyItem();
            }
            this._mainItemData = arg1;
            if (arg1) 
            {
                this._mainItem.dragSource = arg1;
                this._mainItem.itemData = arg1;
                this.setSelectedItem(arg1, this._mainCombo);
                if (this._deputyItemData) 
                {
                    if (arg1.color < this._deputyItemData.color) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(71442));
                        this.onDeputyItemClickHandler(null);
                        return;
                    }
                }
            }
            this.updatePreviewByItemInfo();
            return;
        }

        /* internal  */getMountInComboIndex(arg1: ItemData): int
        {
            var loc3=null;
            var loc1=-1;
            var loc2=this._mainCombo.dataProvider.toArray();
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                if ((loc3 = loc2[loc4].value as ItemData) && loc3.uid == arg1.uid) 
                {
                    loc1 = loc4;
                    break;
                }
                ++loc4;
            }
            return loc1;
        }

        /* internal  */updateDeputyInfo(arg1: ItemData): void
        {
            if (arg1 && arg1.posType == EPlayerItemPosType._EPlayerItemPosTypeRole) 
            {
                MsgManager.showRollTipsMsg(Language.getString(71443));
                return;
            }
            if (arg1 && this._mainItemData && this._mainItemData.uid == arg1.uid) 
            {
                this.clearMainItem();
            }
            if (arg1 && this._mainItemData) 
            {
                if (this._mainItemData.color < arg1.color) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(71442));
                    this.onDeputyItemClickHandler(null);
                    return;
                }
            }
            this._deputyItemData = arg1;
            if (arg1) 
            {
                this._deputyItem.dragSource = arg1;
                this._deputyItem.itemData = arg1;
                this.setSelectedItem(arg1, this._deputyCombo);
            }
            this.updatePreviewByItemInfo();
            return;
        }

        /* internal  */setSelectedItemCombox(arg1: ItemData, arg2: GComboBox): void
        {
            var loc2=null;
            var loc4=null;
            var loc1=arg2.dataProvider;
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                if ((loc2 = loc1.getItemAt(loc3).value as ItemData) && loc2.uid == arg1.uid) 
                {
                    arg2.selectedIndex = loc3;
                    loc4 = ColorConfig.instance.getItemColor(arg1.color);
                    arg2.textField.setStyle("textFormat", new GTextFormat(FontUtil.songtiName, 12, loc4.intColor, null, null, null, null, null, TextAlign.CENTER));
                    break;
                }
                ++loc3;
            }
            return;
        }

        /* internal  */refreshTabData(): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            while (loc3 < FashionBoxMergePanel.EQUITMENTNUM) 
            {
                loc2 = new Map<any, any> /* flash.utils.Dictionary */();
                loc2["name"] = loc3;
                loc2["label"] = loc3;
                loc2["styleName"] = "MergeTab" + loc3;
                loc1.push(loc2);
                ++loc3;
            }
            return loc1;
        }

        protected onRLBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._btnRight:
                {
                    this.btnRightClick();
                    break;
                }
                case this._btnLeft:
                {
                    this.btnLeftClick();
                    break;
                }
            }
            return;
        }

        /* internal  */btnRightClick(): void
        {
            if (this._startIndex + FashionBoxMergePanel.MAX_DISPLAY_LENGTH < this.rtnArray.length) 
            {
                var loc1;
                var loc2=((loc1 = this)._startIndex + 1);
                loc1._startIndex = loc2;
                this._displayListArr = this.getCurrentDisplayList();
                this._tabBar.dataProvider = this._displayListArr;
                this.updateMerge(parseInt(this._tabBar.selectedItem.name) + 1);
            }
            return;
        }

        /* internal  */btnLeftClick(): void
        {
            if (this._startIndex > 0) 
            {
                var loc1;
                var loc2=((loc1 = this)._startIndex - 1);
                loc1._startIndex = loc2;
                this._displayListArr = this.getCurrentDisplayList();
                this._tabBar.dataProvider = this._displayListArr;
                this.updateMerge(parseInt(this._tabBar.selectedItem.name) + 1);
            }
            return;
        }

        /* internal  */getCurrentDisplayList(): Array<any>
        {
            var loc1=[];
            var loc2=this._startIndex + FashionBoxMergePanel.MAX_DISPLAY_LENGTH;
            var loc3=this._startIndex;
            while (loc3 < loc2) 
            {
                loc1.push(this.rtnArray[loc3]);
                ++loc3;
            }
            return loc1;
        }

        /* internal  */tabBarChangeHandler(arg1: MuiEvent): void
        {
            var loc1=arg1.target.selectedItem;
            if (loc1) 
            {
                this.updateMerge(parseInt(loc1.name) + 1);
            }
            return;
        }

        /* internal  */getDataProvider(arg1: Array<any>, arg2: Boolean): DataProvider
        {
            var loc2=null;
            var loc1=new DataProvider();
            var loc3=0;
            while (loc3 < arg1.length) 
            {
                if ((loc2 = arg1[loc3]) && !(loc2 == ItemData.nullItemData)) 
                {
                    if (arg2) 
                    {
                        loc1.addItem({"label": loc2.name, "value": loc2});
                    }
                    else if (loc2.posType == EPlayerItemPosType._EPlayerItemPosTypeBag || loc2.posType == EPlayerItemPosType._EPlayerItemPosTypeWardrobe) 
                    {
                        loc1.addItem({"label": loc2.name, "value": loc2});
                    }
                }
                ++loc3;
            }
            return loc1;
        }

        public updateData(): void
        {
            var loc8=null;
            var loc9=null;
            var loc1=Cache.instance.wardrobe.getItemList(this._wardrobeType);
            this._wingList.updateListPanel(loc1, this._wardrobeType);
            var loc2=this.getDataProvider(loc1, true);
            var loc3=this.getDataProvider(loc1, false);
            if (this._mainCombo.dataProvider && this._mainCombo.dataProvider.length > 0 && this._mainCombo.selectedItem) 
            {
                loc8 = this._mainCombo.selectedItem.value;
            }
            if (this._deputyCombo.dataProvider && this._deputyCombo.dataProvider.length > 0 && this._deputyCombo.selectedItem) 
            {
                loc9 = this._deputyCombo.selectedItem.value;
            }
            var loc4=false;
            var loc5=false;
            var loc6=0;
            while (loc6 < loc2.length) 
            {
                if (loc8 && loc8.uid == loc2.getItemAt(loc6).value.uid) 
                {
                    loc4 = true;
                    this.onMainItemClickHandler(null);
                    this.updateMainInfo(loc2.getItemAt(loc6).value);
                    break;
                }
                ++loc6;
            }
            var loc7=0;
            while (loc7 < loc3.length) 
            {
                if (loc9 && loc9.uid == loc3.getItemAt(loc7).value.uid) 
                {
                    loc5 = true;
                    this.onDeputyItemClickHandler(null);
                    this.updateDeputyInfo(loc3.getItemAt(loc7).value);
                    break;
                }
                ++loc7;
            }
            if (!loc4) 
            {
                this._mainItemData = null;
                this._mainItem.itemData = null;
                this._mainItem.dragSource = null;
                this._mainCombo.selectedIndex = -1;
                this._mainCombo.textColor = GlobalStyle.color1Uint;
                this._previewItem.itemData = null;
                this._previewTxt.text = "";
            }
            if (!loc5) 
            {
                this._deputyItemData = null;
                this._deputyItem.itemData = null;
                this._deputyItem.dragSource = null;
                this._deputyCombo.selectedIndex = -1;
                this._deputyCombo.textColor = GlobalStyle.color1Uint;
                this._previewItem.itemData = null;
                this._previewTxt.text = "";
            }
            this._mainCombo.dataProvider = loc2;
            this._deputyCombo.dataProvider = loc3;
            if (loc8) 
            {
                this.setSelectedItem(loc8, this._mainCombo);
            }
            if (loc9) 
            {
                this.setSelectedItem(loc9, this._deputyCombo);
            }
            this.updatePreviewByItemInfo();
            return;
        }

        /* internal  */setSelectedItem(arg1: ItemData, arg2: GComboBox): void
        {
            var loc1=null;
            var loc3=0;
            var loc4=null;
            var loc2;
            if (loc2 = arg2.dataProvider) 
            {
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    loc1 = loc2.getItemAt(loc3).value as ItemData;
                    if (loc1 && loc1.uid == arg1.uid) 
                    {
                        arg2.selectedIndex = loc3;
                        loc4 = ColorConfig.instance.getItemColor(arg1.color);
                        arg2.textField.setStyle("textFormat", new GTextFormat(FontUtil.songtiName, 12, loc4.intColor, null, null, null, null, null, TextAlign.CENTER));
                    }
                    ++loc3;
                }
            }
            return;
        }

        public resetPanel(): void
        {
            this.clearMainItem();
            this.clearDeputyItem();
            return;
        }

        /* internal  */updatePreviewByItemInfo(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=0;
            var loc5=0;
            var loc6=0;
            var loc7=0;
            var loc8=0;
            var loc9=false;
            var loc10=0;
            var loc11=0;
            if (this._mainItemData && this._deputyItemData) 
            {
                if (this._mergeType != EMergeType._EMergeTypeWing) 
                {
                    if (this._mergeType != EMergeType._EMergeTypeFashion) 
                    {
                        if (this._mergeType != EMergeType._EMergeTypeWeaponFashion) 
                        {
                            if (this._mergeType != EMergeType._EMergeTypeFootprint) 
                            {
                                if (this._mergeType != EMergeType._EMergeTypeBubble) 
                                {
                                    if (this._mergeType != EMergeType._EMergeTypeSurround) 
                                    {
                                        if (this._mergeType != EMergeType._EMergeTypeWaistBelt) 
                                        {
                                            if (this._mergeType == EMergeType._EMergeTypeElf) 
                                            {
                                                loc1 = new ItemData(this._mainItemData.itemExInfo.bELFModel);
                                            }
                                        }
                                        else 
                                        {
                                            loc1 = new ItemData(this._mainItemData.itemExInfo.bWBModel);
                                        }
                                    }
                                    else 
                                    {
                                        loc1 = new ItemData(this._mainItemData.itemExInfo.bSUModel);
                                    }
                                }
                                else 
                                {
                                    loc1 = new ItemData(this._mainItemData.itemExInfo.bbubbleModel);
                                }
                            }
                            else 
                            {
                                loc1 = new ItemData(this._mainItemData.itemExInfo.bFootprintModel);
                            }
                        }
                        else 
                        {
                            loc1 = new ItemData(this._mainItemData.itemExInfo.bWeaponFashionModel);
                        }
                    }
                    else 
                    {
                        loc1 = new ItemData(this._mainItemData.itemExInfo.bFashionModel);
                    }
                }
                else 
                {
                    loc1 = new ItemData(this._mainItemData.itemExInfo.bWindModel);
                }
                loc2 = new ItemExInfo();
                loc3 = this._mainItemData.itemExInfo.strengthen;
                loc4 = this._deputyItemData.itemExInfo.strengthen;
                if (loc3 >= loc4) 
                {
                    loc5 = loc3;
                    this._perBar.setValue(this._mainItemData.itemExInfo.perfectStrengthen, 100);
                }
                else 
                {
                    loc5 = loc4;
                    this._perBar.setValue(this._deputyItemData.itemExInfo.perfectStrengthen, 100);
                }
                loc6 = this._mainItemData.itemExInfo.totalStrengthen;
                loc7 = this._deputyItemData.itemExInfo.totalStrengthen;
                loc8 = loc6 >= loc7 ? loc6 : loc7;
                loc2.strengthen = loc5;
                loc2.totalStrengthen = loc8;
                loc9 = this._mainItemData.itemExInfo.prefix >= this._deputyItemData.itemExInfo.prefix ? true : false;
                if (this._mergeType != EMergeType._EMergeTypeWing) 
                {
                    this._previewTxt.htmlText = ItemsUtil.getItemName(this._mainItemData);
                    if (loc9) 
                    {
                        loc10 = this._mainItemData.itemExInfo.prefix;
                    }
                    else 
                    {
                        loc10 = this._deputyItemData.itemExInfo.prefix;
                    }
                    this.updateAttrbute(this._mainItemData, loc5, loc8, loc10);
                }
                else 
                {
                    this.getWingAttributeAfterMerge(this._mainItemData, this._deputyItemData, loc5, loc8);
                }
                if (loc9) 
                {
                    this._prefixTxt.text = Cache.instance.wardrobe.getPreFixStr(this._mainItemData);
                }
                else 
                {
                    this._prefixTxt.text = Cache.instance.wardrobe.getPreFixStr(this._deputyItemData);
                }
                if (loc1) 
                {
                    loc1.color = this._mainItemData.color;
                    if (this._mergeType == EMergeType._EMergeTypeWing) 
                    {
                        loc11 = this._mainItemData.color >= this._deputyItemData.color ? this._mainItemData.color : this._deputyItemData.color;
                        loc1.color = loc11;
                    }
                    loc1.itemExInfo = loc2;
                    this._previewItem.itemData = loc1;
                }
                this._strengthenTxt.htmlText = "" + loc5;
                this._mergeLevelTxt.htmlText = "" + Cache.instance.wardrobe.getMergeLevelByType(this._wardrobeType, this._deputyItemData);
                this.updateAttributeAdd(this._mainItemData);
            }
            else 
            {
                this._previewItem.dragSource = null;
                this._previewItem.itemData = null;
                this._previewTxt.htmlText = "";
                this._attributeTxt.htmlText = "";
                this._attributeAddTxt.htmlText = "";
                this._strengthenTxt.htmlText = "";
                this._mergeLevelTxt.htmlText = "";
                this._prefixTxt.htmlText = "";
                this._perBar.setValue(0, 100);
            }
            return;
        }

        /* internal  */getWingUpperLevelAttribute(arg1: Array<any>, arg2: int): Array<any>
        {
            var loc1=null;
            var loc2=null;
            var loc4=0;
            var loc3=[];
            while (loc4 < arg1.length) 
            {
                loc1 = arg1[loc4];
                (loc2 = new Map<any, any> /* flash.utils.Dictionary */())["name"] = loc1["name"];
                loc2["value"] = loc1["value"] + arg2;
                loc2["type"] = loc1["type"];
                loc3.push(loc2);
                ++loc4;
            }
            return loc3;
        }

        /* internal  */onMergeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var name: string;
            var tips: string;
            var closeAlert: Function;

            var loc1;
            tips = null;
            e = arg1;
            name = "";
            if (this._mergeType != EMergeType._EMergeTypeFashion) 
            {
                if (this._mergeType != EMergeType._EMergeTypeWeaponFashion) 
                {
                    if (this._mergeType == EMergeType._EMergeTypeWing) 
                    {
                        name = Language.getString(36201);
                    }
                }
                else 
                {
                    name = Language.getString(36202);
                }
            }
            else 
            {
                name = Language.getString(36200);
            }
            if (!this._mainItemData || !this._deputyItemData) 
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(36119, name));
                return;
            }
            if (ItemsUtil.isBind(this._mainItemData) || !ItemsUtil.isBind(this._mainItemData) && !ItemsUtil.isBind(this._deputyItemData)) 
            {
                this.toAlertMerge();
            }
            else 
            {
                closeAlert = (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        toAlertMerge();
                    }
                    return;
                }
                tips = Language.getStringByParam(36120, name, name, name);
                Alert.show(tips, null, Alert.OK | Alert.CANCEL, null, closeAlert);
            }
            return;
        }

        /* internal  */isMainAttributeMax(arg1: Array<any>, arg2: Array<any>): Boolean
        {
            var loc2=0;
            var loc3=0;
            var loc1=arg1.length;
            var loc4=[];
            var loc5=[];
            var loc6=0;
            while (loc6 < loc1) 
            {
                if (arg1[loc6]) 
                {
                    loc4.push(arg1[loc6].value);
                }
                if (arg2[loc6]) 
                {
                    loc5.push(arg2[loc6].value);
                }
                ++loc6;
            }
            var loc7=0;
            while (loc7 < loc1) 
            {
                loc2 = loc2 + loc4[loc7];
                loc3 = loc3 + loc5[loc7];
                ++loc7;
            }
            return loc2 >= loc3 ? true : false;
        }

        /* internal  */getWingAttributeAfterMerge(arg1: ItemData, arg2: ItemData, arg3: int, arg4: int): void
        {
            var loc9=0;
            var loc12=null;
            var loc15=0;
            var loc1=arg1.itemInfo.item.color;
            var loc2=arg2.itemInfo.item.color;
            var loc3=new EquipmentItemDataUtil(arg1);
            var loc4=new EquipmentItemDataUtil(arg2);
            var loc5=loc3.getBasePropArray(false);
            var loc6=loc4.getBasePropArray(false);
            if (loc1 == EColor._EColorOrange && loc2 == EColor._EColorPurple) 
            {
                loc6 = this.getWingUpperLevelAttribute(loc6, 20);
            }
            else if (loc2 == EColor._EColorOrange && loc1 == EColor._EColorPurple) 
            {
                loc5 = this.getWingUpperLevelAttribute(loc5, 20);
            }
            else if (loc1 == EColor._EColorRed && loc2 == EColor._EColorPurple) 
            {
                loc6 = this.getWingUpperLevelAttribute(loc6, 70);
            }
            else if (loc2 == EColor._EColorRed && loc1 == EColor._EColorPurple) 
            {
                loc5 = this.getWingUpperLevelAttribute(loc5, 70);
            }
            else if (loc1 == EColor._EColorRed && loc2 == EColor._EColorOrange) 
            {
                loc6 = this.getWingUpperLevelAttribute(loc6, 50);
            }
            else if (loc2 == EColor._EColorRed && loc1 == EColor._EColorOrange) 
            {
                loc5 = this.getWingUpperLevelAttribute(loc5, 50);
            }
            var loc7=this.isMainAttributeMax(loc5, loc6);
            var loc8=[];
            var loc10=this._mainItemData.itemExInfo.prefix >= this._deputyItemData.itemExInfo.prefix ? true : false;
            if (loc7) 
            {
                loc8 = loc5;
            }
            else 
            {
                loc8 = loc6;
            }
            if (loc10) 
            {
                loc9 = arg1.itemExInfo.prefix;
            }
            else 
            {
                loc9 = arg2.itemExInfo.prefix;
            }
            var loc11=loc1 >= loc2 ? loc1 : loc2;
            this._previewTxt.htmlText = HTMLUtil.addColor(arg1.name, ColorConfig.instance.getItemColor(loc11).color);
            var loc13="";
            var loc14=0;
            while (loc15 < loc8.length) 
            {
                loc12 = loc8[loc15];
                loc14 = EquipmentUtil.getBaseAdditive(loc12["value"], arg3, arg4, loc9);
                loc13 = loc13 + loc12["name"] + "：\t<font color=\'#00ff00\'>" + loc12["value"] + "（+" + loc14 + "）</font>\n";
                ++loc15;
            }
            this._attributeTxt.htmlText = loc13;
            return;
        }

        /* internal  */updateAttrbute(arg1: ItemData, arg2: int, arg3: int, arg4: int): void
        {
            var loc3=null;
            var loc6=0;
            var loc1;
            var loc2=(loc1 = new EquipmentItemDataUtil(arg1)).getBasePropArray(false, arg4);
            var loc4="";
            var loc5=0;
            while (loc6 < loc2.length) 
            {
                loc3 = loc2[loc6];
                loc5 = EquipmentUtil.getBaseAdditive(loc3["value"], arg2, arg3, arg4);
                loc4 = loc4 + loc3["name"] + "：\t<font color=\'#00ff00\'>" + loc3["value"] + "（+" + loc5 + "）</font>\n";
                ++loc6;
            }
            this._attributeTxt.htmlText = loc4;
            return;
        }

        /* internal  */updateAttributeAdd(arg1: ItemData): void
        {
            var loc3=null;
            var loc5=0;
            var loc1=new EquipmentItemDataUtil(arg1);
            var loc2=loc1.getAddtionalArray();
            var loc4="";
            while (loc5 < loc2.length) 
            {
                loc3 = loc2[loc5];
                loc4 = loc4 + loc3["name"] + "：\t<font color=\'#00ff00\'>" + loc3["value"] + "</font>\n";
                ++loc5;
            }
            this._attributeAddTxt.htmlText = loc4;
            return;
        }

        /* internal  */clearDeputyItem(): void
        {
            this._deputyItem.itemData = null;
            this._deputyItemData = null;
            this._deputyCombo.selectedIndex = -1;
            this._deputyCombo.textColor = GlobalStyle.color1Uint;
            this.updatePreviewByItemInfo();
            return;
        }

        public setUndressItem(): void
        {
            var loc1=null;
            var loc2=0;
            if (Cache.instance.wardrobe.undressItemUid != "") 
            {
                loc1 = Cache.instance.wardrobe.getItemList(this._wardrobeType).concat();
                loc2 = 0;
                while (loc2 < loc1.length) 
                {
                    if (Cache.instance.wardrobe.undressItemUid == (loc1[loc2] as ItemData).uid) 
                    {
                        this.updateInfo(loc1[loc2]);
                        Cache.instance.wardrobe.undressItemUid = "";
                        return;
                    }
                    ++loc2;
                }
            }
            return;
        }

        /* internal  */init(): void
        {
            this._wingList = new WingList();
            addChild(this._wingList);
            this._wingList.addEventListener(EventName.updateWingFusion, this.onMergeChangeHandler);
            var loc1=ObjCreate.createFlowerBg(112, 0, 400, 80, this);
            this._tabBar = new GImageButtonTabBar();
            this._tabBar.buttonHeight = 52;
            this._tabBar.buttonWidth = 64;
            this._tabBar.x = 135;
            this._tabBar.y = 15;
            this._tabBar.horizontalGap = 5;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.tabBarChangeHandler);
            this.addChild(this._tabBar);
            this._btnLeft = ObjCreate.createGLoadedButton(ResFileConst.MountStartLeft, 118, 30, 20, 20, this);
            this._btnRight = ObjCreate.createGLoadedButton(ResFileConst.MountStartRight, 485, 30, 20, 20, this);
            this._btnRight.addEventListener(flash.events.MouseEvent.CLICK, this.onRLBtnClick);
            this._btnLeft.addEventListener(flash.events.MouseEvent.CLICK, this.onRLBtnClick);
            var loc2=ObjCreate.createFlowerBg(112, 82, 400, 330, this);
            this._stBmWingFusionBg = ObjCreate.createBitmap("", 83, 78, loc2);
            ObjCreate.createBg(83, 34, 38, 38, loc2, ImagesConst.PackItemBg);
            ObjCreate.createBg(269, 34, 38, 38, loc2, ImagesConst.PackItemBg);
            ObjCreate.createBg(178, 192, 38, 38, loc2, ImagesConst.PackItemBg);
            var loc3=new GTextFormat(FontUtil.songtiName, 14, 15788607, true);
            this._mainTxt = ObjCreate.createTextField("", 79, 10, 70, 30, loc2, loc3);
            this._deputyTxt = ObjCreate.createTextField("", 265, 10, 70, 30, loc2, loc3);
            this._previewTxt = ObjCreate.createTextField("", 170, 231, 120, 20, loc2);
            this._mainItem = this.createGoodsItem(1, 86, 37, 33, 33, loc2);
            this._mainItem.addEventListener(flash.events.MouseEvent.CLICK, this.onMainItemClickHandler);
            this._mainItem.addEventListener(DragEvent.Event_Move_In, this.onMainMoveInHandler);
            this._deputyItem = this.createGoodsItem(2, 272, 37, 33, 33, loc2);
            this._deputyItem.addEventListener(flash.events.MouseEvent.CLICK, this.onDeputyItemClickHandler);
            this._deputyItem.addEventListener(DragEvent.Event_Move_In, this.onDeputyMoveInHandler);
            this._previewItem = this.createGoodsItem(3, 181, 195, 33, 33, loc2);
            this._previewItem.isShowToolTip = false;
            this._mainCombo = ObjCreate.createGComboBox(50, 77, 105, 25, null, loc2);
            this._mainCombo.textColor = GlobalStyle.color1Uint;
            this._mainCombo.dropdown.setStyle("cellRenderer", MountComboBoxItemCellRender);
            this._mainCombo.addEventListener(flash.events.Event.CHANGE, this.onMainComboChangehandler);
            this._deputyCombo = ObjCreate.createGComboBox(235, 77, 105, 25, null, loc2);
            this._deputyCombo.textColor = GlobalStyle.color1Uint;
            this._deputyCombo.dropdown.setStyle("cellRenderer", MountComboBoxItemCellRender);
            this._deputyCombo.addEventListener(flash.events.Event.CHANGE, this.onDeputyComboChangeHandler);
            this._resetBtn = ObjCreate.createGButton(Language.getString(70084), 107, 259, 70, 28, loc2, "ButtonSpecial");
            this._resetBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onResetBtnClickHandler);
            this._mergeBtn = ObjCreate.createGButton(Language.getString(70094), 217, 259, 70, 28, loc2, "ButtonSpecial");
            this._mergeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onMergeBtnClickHandler);
            this._mergeTip = ObjCreate.createTextField("", 44, 302, 292, 20, loc2);
            ObjCreate.createBitmap(ImagesConst.Fire, 20, 290, loc2);
            this._desTx = ObjCreate.createGTextField("", 323, 270, 66, 20, loc2, GlobalStyle.textFormat5);
            this._desTx.htmlText = Language.getString(71127);
            var loc4=ObjCreate.createFlowerBg(513, 0, 178, 411, this);
            ObjCreate.createBg(0, 2, 104, 22, loc4, ImagesConst.TileBg);
            this._stBmStreng = ObjCreate.createBitmap("", 3, 3, loc4);
            this._stBmPrefix = ObjCreate.createBitmap("", 3, 64, loc4);
            this._stBmMerge = ObjCreate.createBitmap("", 3, 94, loc4);
            ObjCreate.createBg(2, 118, 166, 2, loc4, ImagesConst.SplitLine);
            ObjCreate.createBg(0, 122, 104, 22, loc4, ImagesConst.TileBg);
            this._stBmFusionAtrribute = ObjCreate.createBitmap("", 3, 123, loc4);
            ObjCreate.createBg(2, 264, 166, 2, loc4, ImagesConst.SplitLine);
            ObjCreate.createBg(0, 268, 104, 22, loc4, ImagesConst.TileBg);
            this._stBmFusionAttributeAdd = ObjCreate.createBitmap("", 3, 270, loc4);
            LoaderHelp.addResCallBack(ResFileConst.wardrobe, this.onLoadBmResource);
            LoaderHelp.addResCallBack(ResFileConst.mount, this.onLoadBmResourceII);
            var loc5=ObjCreate.createTextField(Language.getString(36123) + "：", 7, 40, 52, 20, loc4);
            this._perBar = new PetProcessBar(ImagesConst.GreenBar10, 110);
            this._perBar.setValue(0, 100);
            this._perBar.x = 55;
            this._perBar.y = 44;
            loc4.addChild(this._perBar);
            var loc6=new GTextFormat("", 12, 11661311, null, null, null, null, null, null, null, null, null, 3);
            this._attributeTxt = ObjCreate.createGTextField("", 5, 150, 165, 120, loc4, loc6);
            this._attributeAddTxt = ObjCreate.createTextField("", 5, 295, 150, 120, loc4, loc6);
            var loc7=new GTextFormat(FontUtil.xingkaiName, 36, 16776960);
            this._strengthenTxt = ObjCreate.createTextField("", 120, 5, 70, 40, loc4, loc7);
            this._mergeLevelTxt = ObjCreate.createTextField("", 100, 84, 70, 40, loc4, loc7);
            this._prefixTxt = ObjCreate.createTextField("", 112, 63, 60, 20, loc4);
            this.rtnArray = this.refreshTabData();
            this._tabBar.dataProvider = this.getCurrentDisplayList();
            this.updateMerge(WardrobeType.WardrobeFashion);
            return;
        }

        public updateCurMerge(): void
        {
            if (this._tabBar.selectedItem) 
            {
                this.updateMerge(parseInt(this._tabBar.selectedItem.name) + 1);
            }
            return;
        }

        public updateMerge(arg1: int): void
        {
            this._tabBar.buttonHeight = 52;
            this._tabBar.buttonWidth = 64;
            this._wardrobeType = arg1;
            this.resetPanel();
            this.updateData();
            if (arg1 != WardrobeType.WardrobeFashion) 
            {
                if (arg1 != WardrobeType.WardrobeFashionWeapon) 
                {
                    if (arg1 != WardrobeType.WardrobeWing) 
                    {
                        if (arg1 != WardrobeType.WardrobeFootPrint) 
                        {
                            if (arg1 != WardrobeType.WardrobeBubble) 
                            {
                                if (arg1 != WardrobeType.WardrobeSurroung) 
                                {
                                    if (arg1 != WardrobeType.WardrobeWaistBelt) 
                                    {
                                        if (arg1 == WardrobeType.WardrobeElf) 
                                        {
                                            this._mergeType = EMergeType._EMergeTypeElf;
                                            this._mainTxt.text = Language.getString(74722);
                                            this._deputyTxt.text = Language.getString(74723);
                                            this._mainCombo.prompt = Language.getString(74724);
                                            this._deputyCombo.prompt = Language.getString(74725);
                                            this._mergeTip.htmlText = Language.getString(74726);
                                            this._desTx.toolTipData = Language.getString(74727);
                                        }
                                    }
                                    else 
                                    {
                                        this._mergeType = EMergeType._EMergeTypeWaistBelt;
                                        this._mainTxt.text = Language.getString(74702);
                                        this._deputyTxt.text = Language.getString(74703);
                                        this._mainCombo.prompt = Language.getString(74704);
                                        this._deputyCombo.prompt = Language.getString(74705);
                                        this._mergeTip.htmlText = Language.getString(74706);
                                        this._desTx.toolTipData = Language.getString(74707);
                                    }
                                }
                                else 
                                {
                                    this._mergeType = EMergeType._EMergeTypeSurround;
                                    this._mainTxt.text = Language.getString(71462);
                                    this._deputyTxt.text = Language.getString(71463);
                                    this._mainCombo.prompt = Language.getString(71464);
                                    this._deputyCombo.prompt = Language.getString(71465);
                                    this._mergeTip.htmlText = Language.getString(71466);
                                    this._desTx.toolTipData = Language.getString(71467);
                                }
                            }
                            else 
                            {
                                this._mergeType = EMergeType._EMergeTypeBubble;
                                this._mainTxt.text = Language.getString(71445);
                                this._deputyTxt.text = Language.getString(71446);
                                this._mainCombo.prompt = Language.getString(71447);
                                this._deputyCombo.prompt = Language.getString(71448);
                                this._mergeTip.htmlText = Language.getString(71449);
                                this._desTx.toolTipData = Language.getString(71450);
                            }
                        }
                        else 
                        {
                            this._mergeType = EMergeType._EMergeTypeFootprint;
                            this._mainTxt.text = Language.getString(71404);
                            this._deputyTxt.text = Language.getString(71405);
                            this._mainCombo.prompt = Language.getString(71406);
                            this._deputyCombo.prompt = Language.getString(71407);
                            this._mergeTip.htmlText = Language.getString(71408);
                            this._desTx.toolTipData = Language.getString(71409);
                        }
                    }
                    else 
                    {
                        this._mergeType = EMergeType._EMergeTypeWing;
                        this._mainTxt.text = Language.getString(36114);
                        this._deputyTxt.text = Language.getString(36115);
                        this._mainCombo.prompt = Language.getString(36116);
                        this._deputyCombo.prompt = Language.getString(36117);
                        this._mergeTip.htmlText = Language.getString(36121);
                        this._desTx.toolTipData = Language.getString(36122);
                    }
                }
                else 
                {
                    this._mergeType = EMergeType._EMergeTypeWeaponFashion;
                    this._mainTxt.text = Language.getString(36203);
                    this._deputyTxt.text = Language.getString(36204);
                    this._mainCombo.prompt = Language.getString(36205);
                    this._deputyCombo.prompt = Language.getString(36206);
                    this._mergeTip.htmlText = Language.getString(36207);
                    this._desTx.toolTipData = Language.getString(36208);
                }
            }
            else 
            {
                this._mergeType = EMergeType._EMergeTypeFashion;
                this._mainTxt.text = Language.getString(36203);
                this._deputyTxt.text = Language.getString(36204);
                this._mainCombo.prompt = Language.getString(36205);
                this._deputyCombo.prompt = Language.getString(36206);
                this._mergeTip.htmlText = Language.getString(36207);
                this._desTx.toolTipData = Language.getString(36208);
            }
            return;
        }

        /* internal  */clearMainItem(): void
        {
            this._mainItem.itemData = null;
            this._mainItemData = null;
            this._mainCombo.selectedIndex = -1;
            this._mainCombo.textColor = GlobalStyle.color1Uint;
            this.updatePreviewByItemInfo();
            return;
        }

        /* internal  */toAlertMerge(): void
        {
            if (this._deputyItemData.color >= EColor._EColorPurple) 
            {
                WingFusionAlertWindow.instance.mode = WingFusionAlertWindow.ValidateMode;
            }
            else 
            {
                WingFusionAlertWindow.instance.mode = WingFusionAlertWindow.NormalMode;
            }
            WingFusionAlertWindow.instance.mergeType = this._mergeType;
            WingFusionAlertWindow.instance.mainItemData = this._mainItemData;
            WingFusionAlertWindow.instance.deputyItemData = this._deputyItemData;
            WingFusionAlertWindow.instance.show();
            return;
        }

        /* internal  */onResetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.resetPanel();
            return;
        }

        /* internal */ static /* const */EQUITMENTNUM: int=8;

        /* internal */ static /* const */MAX_DISPLAY_LENGTH: int=5;

        /* internal */ /* var */_wingList: WingList;

        /* internal */ /* var */_shopTabData: Array<any>;

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_btnRight: GLoadedButton;

        /* internal */ /* var */_btnLeft: GLoadedButton;

        /* internal */ /* var */_startIndex: int=0;

        /* internal */ /* var */_displayListArr: Array<any>;

        /* internal */ /* var */_stBmPrefix: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmMerge: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmFusionAtrribute: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmFusionAttributeAdd: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmWingFusionBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_perBar: PetProcessBar;

        /* internal */ /* var */_mainTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_deputyTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_previewTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mainItem: GoodsItem;

        /* internal */ /* var */_mergeType: int=2;

        /* internal */ /* var */_previewItem: GoodsItem;

        /* internal */ /* var */_mainCombo: GComboBox;

        /* internal */ /* var */_deputyCombo: GComboBox;

        /* internal */ /* var */_resetBtn: GButton;

        /* internal */ /* var */_mergeBtn: GButton;

        /* internal */ /* var */_mergeTip: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeAddTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mergeLevelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_prefixTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_mainItemData: ItemData;

        /* internal */ /* var */_deputyItemData: ItemData;

        /* internal */ /* var */rtnArray: Array<any>;

        /* internal */ /* var */_desTx: GTextFiled;

        /* internal */ /* var */_strengthenTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_stBmStreng: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_wardrobeType: int=1;

        /* internal */ /* var */_deputyItem: GoodsItem;
    }
